home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Format / asn / opt_functs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  1.9 KB  |  108 lines

  1. /* opt_functs.c: sets the Encoder/Decoder Function Routines */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Format/asn/RCS/opt_functs.c,v 6.0 1991/12/18 20:15:43 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Format/asn/RCS/opt_functs.c,v 6.0 1991/12/18 20:15:43 jpo Rel $
  9.  *
  10.  * $Log: opt_functs.c,v $
  11.  * Revision 6.0  1991/12/18  20:15:43  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18.  
  19. #include    "head.h"
  20. #include    "asn.h"
  21.  
  22.  
  23.  
  24. typedef struct funct_tbl {
  25.     char    *key;
  26.     int     (*func_encode) ();
  27.     int    (*func_decode) ();
  28.     } TBL_FUNCTS;
  29.  
  30.  
  31. extern int    encode_gentext();
  32. extern int    decode_gentext();
  33. extern int    encode_teletex();
  34. extern int    decode_teletex();
  35. extern int    encode_motis_6937();
  36. extern int    decode_motis_6937();
  37.  
  38.  
  39. static TBL_FUNCTS  tbl_functs [] = {/* -- Encoder/Decoder of an asn1 -- */
  40.     "ia5",            0,            0,
  41.     "generaltext",        encode_gentext,        decode_gentext,
  42.     "motis-86-6937",    encode_motis_6937,    decode_motis_6937,
  43.     "teletex",        encode_teletex,        decode_teletex,
  44.     "none",            0,            0,
  45.     0,            0,            0
  46.     };
  47.  
  48.  
  49.  
  50. #define IN    1
  51. #define OUT    2
  52.  
  53.  
  54.  
  55. /* ------------------------  Start Routine  --------------------------------- */
  56.  
  57.  
  58.  
  59. opt_functs (ap)
  60. ASNCMD    *ap;
  61. {
  62.  
  63.     PP_TRACE (("opt_functs()"));
  64.  
  65.     if (ap->in_asn.name)
  66.         tbl_srch (ap->in_asn.name, IN, &ap->in_asn.ffunc);
  67.  
  68.     if (ap->out_asn.name)
  69.         tbl_srch (ap->out_asn.name, OUT, &ap->out_asn.ffunc);
  70. }
  71.  
  72.  
  73.  
  74.  
  75.  
  76. /* ----------------------  Static  Routines  -------------------------------- */
  77.  
  78.  
  79.  
  80. static tbl_srch (str, type, base)
  81. char    *str;
  82. int    type;
  83. int    (**base) ();
  84. {
  85.     TBL_FUNCTS    *tbl = tbl_functs;
  86.  
  87.     PP_TRACE (("tbl_srch (%s)", str));
  88.  
  89.     for(; tbl->key != NULLCP; tbl++)
  90.         if(lexequ(str, tbl->key) == 0) {
  91.             switch (type) { 
  92.             case IN:
  93.                 *base = tbl->func_decode;
  94.                 return;
  95.             case OUT:
  96.                 *base = tbl->func_encode;
  97.                 return;
  98.             default:
  99.                 PP_LOG (LLOG_EXCEPTIONS,
  100.                     ("Error: Unknown type '%d'", type));
  101.                 exit(1);
  102.             }
  103.         }
  104.  
  105.     PP_LOG (LLOG_EXCEPTIONS, ("Error: Unknown ASN1 '%s'", str));
  106.     exit(1);
  107. }
  108.